package cn.edu.zucc.leyi.util;

import cn.edu.zucc.leyi.R;
import cn.edu.zucc.leyi.db.dao.DictDao;
import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.Filterable;
import android.widget.TextView;

public class DictionaryAdapter  extends CursorAdapter implements Filterable {
	private LayoutInflater layoutInflater;
	private DictDao dictDao;
	public CharSequence convertToString(Cursor cursor) {
		return cursor == null ? "" : cursor.getString(cursor
				.getColumnIndex("_id"));
	}

	public DictionaryAdapter(Context context, Cursor c, boolean autoRequery) {
		super(context, c, autoRequery);
		// TODO Auto-generated constructor stub
		layoutInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		dictDao=new DictDao(context);

	}


	 

	@Override
	public void changeCursor(Cursor cursor) {
		// TODO Auto-generated method stub
		super.changeCursor(cursor);
	}

	private void setView(View view, Cursor cursor) {
		TextView tvWordItem = (TextView) view;
		tvWordItem.setText(cursor.getString(cursor.getColumnIndex("_id")));

	}

	@Override
	public void bindView(View v, Context context, Cursor c) {
		setView(v, c);
	}

	@Override
	public View newView(Context arg0, Cursor arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		View view = layoutInflater.inflate(R.layout.word_list_item, null);
		setView(view, arg1);
		return view;

	}
}
